﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IceDog.Lib.Farm
{
    public class AnimalDictionary : DictionaryBase
    {

        public AnimalDictionary()
        {

        }

        public void Add(string id, Animal animal)
        {
            Dictionary.Add(id, animal);
        }
        public void Remove(string id)
        {
            Dictionary.Remove(id);
        }

        public Animal this[string id]
        {
            get
            {
                return (Animal)Dictionary[id];
            }
            set
            {
                Dictionary[id] = value;
            }
        }
        /// <summary>
        /// 简单的迭代器
        /// </summary>
        /// <returns></returns>
        public new IEnumerator GetEnumerator()
        {
            foreach (var item in Dictionary.Values)
            {
                yield return (Animal)item;
            }
        }
    }
}
